
#include <QMenuBar>
#include <QMessageBox>
//#include <QtCore/qglobal.h>
#include "plugintemplate.h"
#include "rsgisinterface.h"
#include "rsgiswindow.h"
#include "../RSGISCore/rsgis.h"
#include "QtnRibbonGroup.h"


static const QString sName = QObject::tr( "Open" );
static const QString sDescription = QObject::tr( "open file" );
static const QString sCategory = QObject::tr( "Raster" );
static const QString sPluginVersion = QObject::tr( "Version 0.1" );
static const RSGISPlugin::PLUGINTYPE sPluginType = RSGISPlugin::UI;
static const QString sPluginIcon = ":/[pluginlcasename]/[pluginlcasename].png";



PluginTemplate::PluginTemplate(RSGISInterface *pInterface) :
    RSGISPlugin( sName, sDescription, sCategory, sPluginVersion, sPluginType ),
    m_Interface( pInterface )
{

}

PluginTemplate::~PluginTemplate()
{

}

void PluginTemplate::initGui()
{
    m_QActionPointer = new QAction( QIcon( ":/[pluginlcasename]/[pluginlcasename].png" ), tr( "Open" ), this );
    m_QActionPointer->setObjectName( "mQActionPointer" );

    m_QActionPointer->setWhatsThis( tr( "Replace this with a short description of what the plugin does" ) );

    connect( m_QActionPointer, SIGNAL( triggered() ), this, SLOT( run() ) );

    RibbonBar* pRibbonBar = m_Interface->mainWindow()->ribbonBar();
    if ( nullptr == pRibbonBar)
    {
        pRibbonBar = new RibbonBar(m_Interface->mainWindow());
    }
    pRibbonBar->addPage(tr("PluginTemplate"))->addGroup(tr("Plugin"))->addAction(m_QActionPointer);


}

void PluginTemplate::run()
{
    QMessageBox::information(nullptr ,
                             tr("tip") ,
                             tr("tip") ,
                             QMessageBox::Ok );

}

void PluginTemplate::unload()
{

}

void PluginTemplate::help()
{

}




RSGISEXTERN RSGISPlugin * classFactory( RSGISInterface * theQgisInterfacePointer )
{
  return new PluginTemplate( theQgisInterfacePointer );
}

RSGISEXTERN QString name()
{
  return sName;
}


RSGISEXTERN QString description()
{
  return sDescription;
}


RSGISEXTERN QString category()
{
  return sCategory;
}


RSGISEXTERN int type()
{
  return sPluginType;
}


RSGISEXTERN QString version()
{
  return sPluginVersion;
}

RSGISEXTERN QString icon()
{
  return sPluginIcon;
}


RSGISEXTERN void unload( RSGISPlugin * thePluginPointer )
{
  delete thePluginPointer;
}

